package com.zyx.controller;

import com.zyx.mapper.PermissionMapper;
import com.zyx.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

@Controller
public class IndexController {
    @Autowired
    private UserMapper userMapper;

    @Autowired
    private PermissionMapper pm;

    @RequestMapping
    public String index(Model m){
        m.addAttribute("msg","汉化版中心信息");
        return "index";
    }

    public Map<String,Object> init(HttpSession s){
        Map<String,Object> map = new HashMap<>();
        Map<String,Object> m1 = new HashMap<>();
        m1.put("title","首页");
        m1.put("href","home");
        map.put("homeInfo",m1);

        Map<String,String> m2 = new HashMap<>();
        m2.put("title","碳积分管理系统");
        m2.put("href","home");
        m2.put("image","images/logo.png");
        map.put("logoInfo",m2);

        Map<String,Object> menu = new HashMap<>();
        menu.put("title","默认左侧菜单");
        menu.put("icon","fa fa-address-book");
        menu.put("href","javascript:void(0)");
        menu.put("target","_self");
        menu.put("child",pm.menu(s.getAttribute("account").toString()));


        return map;
    }

    
}
